package model

type ESArticle struct {
	ID             int      `json:"id"`
	Title          string   `json:"title"`
	Body           string   `json:"body"`
	Tags           []string `json:"tags"`
	AuthorUsername string   `json:"author_username"`
	AuthorID       int      `json:"author_id"`
	CategoryName   string   `json:"category_name"`
}

func (e ESArticle) IndexName() string {
	return "article"
}

func (e ESArticle) ESArticleMapping() string {
	mapping := `{
	"mappings": {
		"properties": {
			"id": {"type": "integer"},
			"title": {"type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_smart"},
			"body": {"type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_smart"},
			"tags": {"type": "keyword"},
			"category_name": {"type": "keyword"},
			"author_username": {"type": "keyword"},
			"author_id": {"type": "integer"}
		}
	}
}`
	return mapping
}

// func ESArticleMapping() string {
// 	mapping := `{
// 	"mappings": {
// 		"properties": {
// 			"title": {"type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_smart"},
// 			"body": {"type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_smart"},
// 			"tags": {"type": "keyword"},
// 			"pub_time": {"type": "date"},
// 			"author_id": {"type": "integer"},
// 			"category_id": {"type": "integer"}
// 		}
// 	}
// }`
// 	return mapping
// }
